#include <cmath>
#include <cstdio>

const int N = 200005;
int n, m, a[N];
struct Node {
  double ssin, ccos, tag;
} tr[N << 2];

inline void pushup(int x) {
  tr[x].ssin = tr[x << 1].ssin + tr[x << 1 | 1].ssin;
  tr[x].ccos = tr[x << 1].ccos + tr[x << 1 | 1].ccos;
}

inline void pushdown(int x) {
  static int ls, rs;
  static double osin, ocos;
  if (tr[x].tag) {
    ls = x << 1, rs = x << 1 | 1, osin = tr[ls].ssin, ocos = tr[ls].ccos;
    tr[ls].ssin = osin * cos(tr[x].tag) + ocos * sin(tr[x].tag);
    tr[ls].ccos = ocos * cos(tr[x].tag) - osin * sin(tr[x].tag);
    osin = tr[rs].ssin, ocos = tr[rs].ccos;
    tr[rs].ssin = osin * cos(tr[x].tag) + ocos * sin(tr[x].tag);
    tr[rs].ccos = ocos * cos(tr[x].tag) - osin * sin(tr[x].tag);
    tr[ls].tag += tr[x].tag;
    tr[rs].tag += tr[x].tag;
    tr[x].tag = 0;
  }
}

void build(int x, int l, int r) {
  if (l == r) return (void)(tr[x].ssin = sin(a[l]), tr[x].ccos = cos(a[l]));
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  pushup(x);
}

double query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return tr[x].ssin;
  int mid = (l + r) >> 1;
  double res = 0;
  pushdown(x);
  if (L <= mid) res += query(x << 1, l, mid, L, R);
  if (mid < R) res += query(x << 1 | 1, mid + 1, r, L, R);
  return res;
}

void modify(int x, int l, int r, int L, int R, int v) {
  if (L <= l && r <= R) {
    double osin = tr[x].ssin, ocos = tr[x].ccos;
    tr[x].ssin = osin * cos(v) + ocos * sin(v);
    tr[x].ccos = ocos * cos(v) - osin * sin(v);
    tr[x].tag += v;
    return;
  }
  pushdown(x);
  int mid = (l + r) >> 1;
  if (L <= mid) modify(x << 1, l, mid, L, R, v);
  if (mid < R) modify(x << 1 | 1, mid + 1, r, L, R, v);
  pushup(x);
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  build(1, 1, n);
  scanf("%d", &m);
  int l, r, opt, v;
  while (m--) {
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d%d%d", &l, &r, &v);
      modify(1, 1, n, l, r, v);
    } else {
      scanf("%d%d", &l, &r);
      printf("%.1lf\n", query(1, 1, n, l, r));
    }
  }
  return 0;
}
